package bpel.types;

import java.util.HashMap;
import java.util.LinkedList;

/**
 * 
 * @author Maurice & Topia
 *
 */
public class BPELComplexType extends BPELType{
	
	private String name;
	private HashMap<String, BPELElement> elements;
	
	public BPELComplexType(String name) {
		this.name = name;
		this.elements = new HashMap<String, BPELElement>();
	}
	
	public void addElement(String name, BPELElement element){
		elements.put(name, element);
	}
	
	public void addElements(LinkedList<BPELElement> elements){
		for(BPELElement element : elements){
			addElement(element.getName(), element);
		}
	}
	
	public HashMap<String, BPELElement> getElements() {
		return elements;
	}
	
	public void setName(String name){
		this.name = name;
	}

	@Override
	public String getName() {
		return name;
	}
	
	@Override
	public String toString() {
		String typeStr = "complexType " + name + "{\n";

		for (String e : elements.keySet()) {
			typeStr += elements.get(e).toString() + "\n";
		}

		typeStr += "};\n";

		return typeStr;
	}

	@Override
	public String getTypeNodeName() {
		return "complexType";
	}
}